home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / internet-drafts / draft-ietf-x400ops-tbl-dist-part1.txt < prev    next >
Text File  |  1993-07-08  |  69KB  |  2,205 lines

  1.  
  2.         
  3. INTERNET DRAFT                                            Marko Kaittola
  4.                                                                    FUNET
  5.                                                             Jul 04, 1993
  6.                                                   Expires: January, 1994
  7.         
  8.         
  9.         
  10.         
  11.                       Mail based file distribution
  12.                     Part 1: Dialog between two nodes
  13.         
  14.                              Marko Kaittola
  15.                                  FUNET
  16.         
  17.         
  18. Abstract
  19.         
  20.         Mapping between X.400 and Internet mail and X.400 routing
  21.         are normally done using a table-based approach. In practise
  22.         tables are normal (ASCII) files. In order to function
  23.         properly tables must be coordinated carefully. One major
  24.         problem is the lack of automated procedures. This memo -
  25.         together with it's companion document - proposes one
  26.         possible solution. This memo discusses the transactions
  27.         between two nodes, while the companion document discusses
  28.         the over-all structure aspects.
  29.         
  30.         The same solution can be used to transport binary files.
  31.         This way it is possible to mirror an entire archive with
  32.         an e-mail only connectivity.
  33.         
  34.         
  35. Status of this memo
  36.         
  37.         This document is an Internet Draft.  Internet Drafts are
  38.         working documents of the Internet Engineering Task Force
  39.         (IETF), its Areas, and its Working Groups.  Note that other
  40.         groups may also distribute working documents as Internet
  41.         Drafts.
  42.         
  43.         Internet Drafts are draft documents valid for a maximum of
  44.         six months.  Internet Drafts may be updated, replaced, or
  45.         obsoleted by other documents at any time.  It is not
  46.         appropriate to use Internet Drafts as reference material or
  47.         to cite them other than as a ``working draft'' or ``work in
  48.         progress.''
  49.         
  50.         Please check the 1id-abstracts.txt listing contained in the
  51.         internet-drafts Shadow Directories on nic.ddn.mil,
  52.         nnsc.nsf.net, nic.nordu.net, ftp.nisc.sri.com, or
  53.         munnari.oz.au to learn the current status of any Internet
  54.         Draft.
  55.         
  56.  
  57.  
  58. Kaittola                 Expires: January, 1994                 [Page 1]
  59.  
  60. DRAFT                  File distribution - dialog                  DRAFT
  61.  
  62.  
  63.         Distribution of this memo is unlimited.
  64.         
  65.         
  66. Table of contents
  67.         
  68.         Abstract                                                    1
  69.         Status of this memo                                         1
  70.         Table of contents                                           2
  71.         1. Introduction                                             3
  72.         1.1. About security                                         3
  73.         1.2. Terminology                                            4
  74.         2. Notation                                                 5
  75.         3. Parsing                                                  6
  76.         4. Dialog                                                   8
  77.         4.1. Ihave                                                 10
  78.         4.2. Sendme                                                13
  79.         4.3. Data                                                  15
  80.         4.4 List                                                   18
  81.         4.5. Ping                                                  19
  82.         4.6. Pong                                                  19
  83.         4.7. Contents of data                                      20
  84.         5. Coding and checksums                                    23
  85.         5.1. Some background                                       23
  86.         5.2. Calculating the checksum                              23
  87.         6. Security consideratins                                  26
  88.         References                                                 26
  89.         Acknowledgements                                           26
  90.         Author's address                                           26
  91.         Appendix A: BNF summary - initial parsing                  28
  92.         Appendix B: BNF summary - message structure                29
  93.         Appendix C: BNF summary - data message parsing             36
  94.         Appendix D: Checksum function by Pasi Ojala                38
  95.         
  96.         
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. Kaittola                 Expires: January, 1994                 [Page 2]
  117.  
  118. DRAFT                  File distribution - dialog                  DRAFT
  119.  
  120.  
  121. 1. Introduction
  122.         
  123.         This paper defines a dialog between two nodes. [DST-PICTURE]
  124.         defines a way how this dialog is used. These two documents
  125.         should be read together. A third document should also be
  126.         written. That document [DST-MHS] should explain how the
  127.         other two documents are applied to the needs of X.400
  128.         world.
  129.         
  130.         This paper has grown from a real need: mapping and routing
  131.         information in the international R&D X.400 network must be
  132.         distributed automatically.
  133.         
  134.         The most obvious solution would be to use FTP, but
  135.         unfortunately this isn't always possible. Indeed, the only
  136.         common denominator seems to be some kind of e-mail
  137.         connectivity, so this is what the distribution must be based
  138.         on. Naturally, other distribution techniques may (and most
  139.         probably will) be used in addition to this.
  140.         
  141.         Using a directory (either dns or X.500) is a natural and
  142.         attractive alternative. This, however, is not yet realistic
  143.         in a global scale.
  144.         
  145.         This proposal tries to fulfill the following requirements:
  146.         
  147.         - Files must be distributed rather quickly. In practice
  148.           this means some minutes from one node to another. Files
  149.           should reach even their final destination within a
  150.           couple of hours.
  151.         - Transport errors and forged files must be automatically
  152.           identified (and appropriate actions taken).
  153.         - Management must be simple and require very little human
  154.           effort.
  155.         - Distribution must be based on e-mail.
  156.         
  157.         This task is simplified by the fact that files are normally
  158.         public in a sense that anyone may fetch and see them.
  159.         
  160.         
  161. 1.1. About security
  162.         
  163.         This memo defines a secure way for two nodes to communicate
  164.         together. The over-all structure is discussed in the
  165.         companion document [DST-PICTURE].
  166.         
  167.         Security is based on a three-phase dialog. The first phase
  168.         in the initiation of the dialog. It is possible to fake an
  169.         initiation message ("Ihave message"), but doing so doesn't
  170.         compromise the security.
  171.         
  172.  
  173.  
  174. Kaittola                 Expires: January, 1994                 [Page 3]
  175.  
  176. DRAFT                  File distribution - dialog                  DRAFT
  177.  
  178.  
  179.         In the second thase the client send a key to the server. It
  180.         is expected that although the source of an e-mail is
  181.         impossible to know the target can be known. Thus the client
  182.         can be sure that the key is sent to a real server that has
  183.         been pre-configured on it's database.
  184.         
  185.         In the third phase the server respondes. The authentity of
  186.         the message is checked using the key defined in the second
  187.         phase.
  188.         
  189.         Neither line tapping nor system security are considered. It
  190.         is expected that if one can listen to the traffic on a line
  191.         or become a super user one can break the file distribution
  192.         any way he likes.
  193.         
  194.         Doing the key management as part of the dialog simplifies
  195.         it greatly.
  196.         
  197.         
  198. 1.2. Terminology
  199.         
  200.         A client is a node that receives files and a notification
  201.         about new files.
  202.         
  203.         A server is a node that sends files and a notification
  204.         about new files. If there is a bi-directional link between
  205.         any two nodes they can both be clients and servers to each
  206.         other.
  207.         
  208.         Terms client and server are relative to a particular pair of
  209.         nodes.
  210.         
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232. Kaittola                 Expires: January, 1994                 [Page 4]
  233.  
  234. DRAFT                  File distribution - dialog                  DRAFT
  235.  
  236.  
  237. 2. Notation
  238.         
  239.         |        choice
  240.         []        optional
  241.         <CR>        end of line (it can be Carriage Return or
  242.                 Line Feed or anything, system specific)
  243.         ()        group
  244.         <name>        named rule
  245.         *        repeated zero or more times
  246.         *n        repeated at most n times
  247.         m*n        repeated between m and n times
  248.         m*        repeated at least m times
  249.         --        start of comment
  250.         <l>        letter (a-z), case-insensitive
  251.         <d>        digit (0-9)
  252.         <ldh>        letter (a-z), digit (0-9) or hyphen ("-"),
  253.                 case-insensitive
  254.         <SP>        white space (ie. space and tab)
  255.         <S>        space (" ")
  256.         <any>        any single ASCII character except <CR>
  257.         <(>        open parenthis
  258.         <)>        close parenthis
  259.         <[>        open brace
  260.         <]>        close brace
  261.         anything else    literal
  262.         
  263.         Implementation must be case insensitive with one exeption:
  264.         file (and directory) names are case sensitive.
  265.         
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290. Kaittola                 Expires: January, 1994                 [Page 5]
  291.  
  292. DRAFT                  File distribution - dialog                  DRAFT
  293.  
  294.  
  295. 3. Parsing
  296.         
  297.         This chapter explains how the parsing of a message is
  298.         done.  Although it is logically done in multiple phases
  299.         there is no reason why all of these logical phases couldn't
  300.         be in practice combined into one run.
  301.         
  302.         In general a mail message consists of headers and a body.
  303.         (And an envelope, too. But as an envelope bolongs to MTAs
  304.         and not UAs it can safely be ignored in this context.)
  305.         Parsing starts by stripping the headers away.
  306.         
  307.         In the second phase trailing white spaces will be removed.
  308.         
  309.         In the third phase comments will be removed. A comment is a
  310.         line that starts with a hash (#), or formally
  311.         
  312.         <comment>    ::=
  313.             # <any>* <CR>    -- A line starting with a "#" is
  314.                     -- a comment.
  315.         
  316.         In the fourth phase empty lines will be removed.
  317.         
  318.         In the fifth phase the folding of lines will be undone.
  319.         
  320.         A logical line may be folded into multiple physical lines.
  321.         In practise this will occur if the original (logical) line
  322.         is considered to be too long. A folded line is formally
  323.         defined like this:
  324.         
  325.         <folded-line>    ::=
  326.             <any>1* ( \ <CR> <SP>1* <any>1* )1* <CR>
  327.                        -- Note that there are no
  328.                        -- insignificant spaces before
  329.                               -- the backslash. If there is a space
  330.                               -- it is significant. Spaces in front 
  331.                               -- of the continuation line(s) are 
  332.                        -- insignificant and will be removed
  333.                        -- while putting the physical lines
  334.                        -- together.
  335.         
  336.         For example:
  337.         
  338.         This is an \
  339.          example on \
  340.             how li\
  341.          nes can be folded.
  342.         
  343.         produces
  344.         
  345.         This is an example on how lines can be folded.
  346.  
  347.  
  348. Kaittola                 Expires: January, 1994                 [Page 6]
  349.  
  350. DRAFT                  File distribution - dialog                  DRAFT
  351.  
  352.  
  353.         
  354.         As can be seen, a line can be folded even in the middle of a
  355.         word.
  356.         
  357.         Finally, when all of this is done the "real" parsing starts
  358.         (in the sixth phase). This is defined in chapter four.
  359.         Please note that chapter four only deals with the sixth
  360.         phase and the logical lines.
  361.         
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406. Kaittola                 Expires: January, 1994                 [Page 7]
  407.  
  408. DRAFT                  File distribution - dialog                  DRAFT
  409.  
  410.  
  411. 4. Dialog
  412.         
  413.         There are normally three phases in a normal
  414.         ("ihave-sendme-data_or_command") dialog, but it can also
  415.         start from the phase 2. Phases 2 and 3 can also be replased
  416.         by using FTP.
  417.         
  418.         Doing the dialog in three phases helps to keep it secure,
  419.         but it also makes the distribution on a large network
  420.         (relatively) fast and it saves network bandwith.
  421.         
  422.         Graphically it can be presented as in the picture 1:
  423.         
  424.         
  425.         SERVER                   |        |                   CLIENT
  426.                                  |        |
  427.         Send a notification      |-       |
  428.                                  |  \     |
  429.                                  |    1   | IHAVE
  430.                                  |      \ |
  431.                                  |       -|   Receive a notification
  432.                                  |        |
  433.                                  |       -|           Send a request
  434.                                  |      / |
  435.                                  |    2   | SENDME
  436.                                  |  /     |
  437.         Receive a request        |-       |
  438.                                  |        |
  439.         Send files or            |-       |
  440.         command                  |  \     |
  441.                                  |    3   | DATA or COMMAND
  442.                                  |      \ |
  443.                                  |       -|         Receive files or
  444.                                  |        |                  command
  445.                                  |        |
  446.         
  447.         
  448.         Picture 1
  449.         
  450.         
  451.         Phase 1: The server sends a message to a client informing it
  452.              about the availability of new files or commands.
  453.              There is no authentication in this phase, although
  454.              the client may try to see if the notification seems
  455.              to come from an approved source.
  456.         
  457.         Phase 2: The client sends a request to the server. In this
  458.              request the client specifies a key that the server
  459.              must use when it replies. The client also stores
  460.              the key in its local data base.
  461.         
  462.  
  463.  
  464. Kaittola                 Expires: January, 1994                 [Page 8]
  465.  
  466. DRAFT                  File distribution - dialog                  DRAFT
  467.  
  468.  
  469.         Phase 3: The server responds to the client. Usually this
  470.              means sending the requested files, but
  471.              occasionally the server may tell that the files
  472.              are not available. If the client is requesting a
  473.              command and it is available, the server responds
  474.              with the requested command if it is available. When
  475.              the client receives a reply it checks the validity
  476.              of that submission based on the key specified in
  477.              phase 2.
  478.         
  479.         There are also variations of the dialog ("ping-pong" and
  480.         "list-data").  These are presented in the picture 2.
  481.         
  482.         
  483.         SERVER                   |        |                   CLIENT
  484.                                  |        |
  485.                                  |       -|      Send a ping message
  486.                                  |      / |
  487.                                  |    1   | PING
  488.                                  |  /     |
  489.         Receive a ping message   |-       |
  490.                                  |        |
  491.         Send a ping reply        |-       |
  492.                                  |  \     |
  493.                                  |    2   | PONG
  494.                                  |      \ |
  495.                                  |       _|     Receive a ping reply
  496.                                  |        |
  497.                                  |        |
  498.                                  |        |
  499.                                  |       -|      Send a list request
  500.                                  |      / |
  501.                                  |    1   | LIST
  502.                                  |  /     |
  503.         Receive a list request   |-       |
  504.                                  |        |
  505.         Send a listing           |-       |
  506.                                  |  \     |
  507.                                  |    2   | DATA LIST
  508.                                  |      \ |
  509.                                  |       -|        Receive a listing
  510.                                  |        |
  511.         
  512.         
  513.         Picture 2
  514.         
  515.         Phase 1 (ping): The client sends a ping message for test
  516.                         purposes.
  517.         
  518.         Phase 2 (pong): The server responds with a pong message.
  519.                         There is no authorization in this dialog
  520.  
  521.  
  522. Kaittola                 Expires: January, 1994                 [Page 9]
  523.  
  524. DRAFT                  File distribution - dialog                  DRAFT
  525.  
  526.  
  527.                 (but naturally there is validation).
  528.         
  529.         Phase 1 (list): The client sends a list message to receive a
  530.                         listing of available files.
  531.         
  532.         Phase 2 (data): The server responds with a data message.
  533.                 This message contains the required listing
  534.                 or an error message. As in a pong message,
  535.                 there is no authorization but there is
  536.                 validation.
  537.         
  538.         Doing the distribution in one phase (just sending files) has
  539.         the following important drawbacks:
  540.         
  541.         - If there are loops on a distribution a client will receive
  542.           multiple copies of the same file. If the file is big this
  543.           is serious wasting of capasity.
  544.         - Security must be based on keys that have been set up by
  545.           hand and that are managed by hand. This is an
  546.           administrative headache.
  547.         - It is not possible to request a missing file.
  548.         
  549.         Doing the distribution in two phase (just request a file and
  550.         wait for it) has the following important drawbacks:
  551.         
  552.         - It is a slow way to distribute information.
  553.         - If there are loops on a distribution a client will receive
  554.           multiple copies of the same file. If the file is big this
  555.           is serious wasting of capasity.
  556.         - It isn't possible to fast send a file to replase an
  557.           incorrect version of it.
  558.         
  559.         
  560. 4.1. Ihave
  561.         
  562.         The server sends an IHAVE message to inform the recipient(s)
  563.         about the file(s) or command(s) it has received or made
  564.         available. The following information will be present:
  565.         
  566.         - file name
  567.         - version number
  568.         - name of distributor
  569.         
  570.         It should be noticed that although file names and
  571.         directory names are case sensitive not all systems support
  572.         this. The following conventions are strongly suggested:
  573.         
  574.         - File names are written in small letters.
  575.         - Directory names are written in capital letters.
  576.         
  577.         It should be noted that a special directory "Cmds" with it's
  578.  
  579.  
  580. Kaittola                 Expires: January, 1994                [Page 10]
  581.  
  582. DRAFT                  File distribution - dialog                  DRAFT
  583.  
  584.  
  585.         subdirectories is reserved to transmit commands. All of it's
  586.         subdirectories must be written in capital letters.
  587.         
  588.         Naturally it is a local matter on how files and directories
  589.         are stored locally.
  590.         
  591.         For example:
  592.         
  593.         # Directory/name
  594.         IHAVE:     FILE TXT COSINE-MHS/mapping-1
  595.         # Version number is HHMMSS-DDMMYY
  596.         VERSION: 930317-121303
  597.         FTP: nic.switch.ch:/cosine-mhs/mappings/mapping-1;\
  598.              anonymous;user@domain
  599.         # RFC-addr between a pair of "<>", OR-addr using /-notation.
  600.         IAM:     <cosine-server@cosine-mhs.switch.ch>
  601.         
  602.         or
  603.         
  604.         # Command
  605.         IHAVE: CMD Cmds/COSINE-MHS/new-file
  606.         VERSION: 930424-020127
  607.         IAM: /S=cosine-server/OU=cosine-mhs/O=switch/PRMD=SWITCH/\
  608.              ADMD=ARCOM/C=CH/
  609.         
  610.         Formal definition:
  611.         
  612.         <I-msg>        ::=    -- IHAVE message
  613.             ( <I-line> <V-line> [<FTP-line>] )1*
  614.             <IAM-line>
  615.         
  616.         <I-line>    ::=    -- Commands are given in a special
  617.                     -- file 
  618.             IHAVE: <SP>* ( FILE ( TXT | BINARY ) | CMD ) <SP>*
  619.             <file-name> <CR>
  620.         
  621.         <file-name>    ::=
  622.             <directory>* <filename>
  623.                     -- File name is a symbolic name,
  624.                     -- although it looks like a Unix
  625.                     -- file name.
  626.         
  627.         <directory>    ::=
  628.             <l> (<ldh>|_)*14 /
  629.                     -- for example: "COSINE-MHS/"
  630.                     -- This is case-sensitive, but it
  631.                     -- is suggested that capital letters
  632.                     -- are used for a directory whenever
  633.                     -- possible. A special directory
  634.                     -- name "Cmds" (and it's
  635.                     -- subdirectories) are reserved for
  636.  
  637.  
  638. Kaittola                 Expires: January, 1994                [Page 11]
  639.  
  640. DRAFT                  File distribution - dialog                  DRAFT
  641.  
  642.  
  643.                     -- commands. It is explicitly
  644.                     -- forbidden to store any (normal)
  645.                     -- files there.
  646.         
  647.         <filename>    ::=
  648.             <l> (<ldh>|_)*14 [ . ( <ldh> | _ )1*14 ]
  649.                     -- For example: "mapping-1" or
  650.                     -- "a_long_file.extension". This is
  651.                     -- case-sensitive, but small
  652.                     -- letters are suggested for a file
  653.                     -- name whenever possible.
  654.         
  655.         <V-line>    ::=
  656.             VERSION: <SP>* <vers-number> <CR>
  657.         
  658.         <vers-number>    ::=
  659.             <d>6*6 - <d>6*6    -- This must be YYMMDD-hhmmss.
  660.                     -- No timezone is specified. It is
  661.                     -- assumed to be local to the
  662.                     -- node that issues the version
  663.                     -- number. 
  664.         
  665.         <FTP-line>    ::=
  666.             FTP: <SP>* <host> : <ftp-file> <SP>* ; <SP>*
  667.             <user> <SP>* ; <SP>* <pass> <CR>
  668.                        -- FTP is one more option for getting
  669.                        -- a file. This line doesn't have to
  670.                        -- be present. Even if it is present
  671.                        -- also normal method (mail) must be
  672.                        -- available.
  673.         
  674.         <host>            ::=
  675.             ( <host-component> ( . <host-component> )1* ) |
  676.             <[> <d>1*3 ( . <d>1*3 )3*3 <]>
  677.                     -- Look at [RFC-952] and
  678.                     -- [RFC-1123] to see the source of
  679.                     -- this definition.
  680.         
  681.         <host-component> ::=
  682.             ( <l> | <d> ) <ldh>1*
  683.         
  684.         <ftp-file>    ::=    -- The name of the file to be get
  685.             <any>1*        -- using FTP. Even a semicolon may
  686.                     -- be part of it.
  687.         
  688.         <user>        ::=    -- Username to be given.
  689.             <ld>1*
  690.         
  691.         <pass>        ::=    -- Password to be given.
  692.             <any>1*        -- there are two reserved passwords:
  693.                     -- "user@domain" is intended for
  694.  
  695.  
  696. Kaittola                 Expires: January, 1994                [Page 12]
  697.  
  698. DRAFT                  File distribution - dialog                  DRAFT
  699.  
  700.  
  701.                     -- those anonymous FTP servers that
  702.                     -- require a password consisting of
  703.                     -- real username and domainname to
  704.                     -- be used. It should be replased
  705.                     -- with actual data. "SECRET" means
  706.                     -- that password has to be known by
  707.                     -- some other means.
  708.         
  709.         <IAM-line>    ::=
  710.             IAM: <SP>* <addr> <CR>
  711.         
  712.         <addr>        ::=
  713.             <RFC-addr> | <OR-addr> | ( <RFC-addr> <SP>* <OR-addr> )
  714.                     -- Also some other kind of address
  715.                     -- could be used. However, it must
  716.                     -- not start or end either with "//"
  717.                     -- nor with "<>".
  718.                     -- Listing both RFC-address and OR
  719.                     -- address might make sense as the
  720.                     -- sender doesn't always know
  721.                     -- which one is more appropriate
  722.                     -- form.
  723.         
  724.         <RFC-addr>    ::=
  725.                     -- Normal, valid RFC-822 address
  726.                     -- enclosed in "<>" pair.
  727.         
  728.         <OR-addr>    ::=
  729.                     -- Normal valid OR address using
  730.                     -- "/ notation" not enclosed in
  731.                     -- "<>" pair.
  732.         
  733.         
  734. 4.2. Sendme
  735.         
  736.         In SENDME message the recipient asks for one or more files
  737.         or commands. A key is given in the request. It is possible
  738.         to request either a specific version or the latest version.
  739.         
  740.         For example:
  741.         
  742.         SENDME:    FILE COSINE-MHS/mapping-1
  743.         # VERSION is either
  744.         #    newest    for newest available version
  745.         #    ihave #    I have version #; send me the newest if it
  746.         #    isn't this (or smaller)
  747.         #    #    send me version #
  748.         VERSION:    newest
  749.         # Don't bother compressing before sending
  750.         COMPRESSION: NONE
  751.         # Data size must not be more that 60 kb in a message.
  752.  
  753.  
  754. Kaittola                 Expires: January, 1994                [Page 13]
  755.  
  756. DRAFT                  File distribution - dialog                  DRAFT
  757.  
  758.  
  759.         # If there is more data then it must be split into moltiple
  760.         # messages.
  761.         MAXSIZE: 60
  762.         IAM:    <cosine-user@funet.fi>
  763.         KEY:    1234567890abcdefghij
  764.         SERIAL:    123
  765.         
  766.         Formal definition:
  767.         
  768.         <S-msg>    ::=        -- SENDME message
  769.             ( <S-line> <V-line> <CMP-line> )1*
  770.             <MAX-line>
  771.             <IAM-line>
  772.             <K-line>
  773.             <E-line>
  774.         
  775.         <S-line>    ::=        -- SENDME line
  776.             SENDME: <SP>* ( FILE | CMD ) <CR>
  777.             <SP>* <file-name> <CR>
  778.         
  779.         <CMP-line>    ::=
  780.             COMPRESSION: <SP>* NONE | 
  781.                      ( IS <SP>* <compression> ) |
  782.                      ( CAN <SP>* <compression> [ ; <SP>*
  783.                                      <compression> ] )
  784.             <CR>        -- In sendme-message compression can
  785.                     -- be either NONE or it can be a
  786.                     -- list of possible compressions
  787.                     -- (CAN alternative). In data-
  788.                     -- message it can be either NONE
  789.                     -- or the name of used compression
  790.                     -- (IS-alternative). The idea is
  791.                     -- that when a message is being
  792.                     -- requested it is possible to
  793.                     -- specify all of the possible
  794.                     -- compressions. The server may
  795.                     -- pick one of them, or it may use
  796.                     -- no compression at all.
  797.         
  798.         
  799.         <compression>    ::=
  800.             <ldh>1*15    -- The name of the used compression.
  801.                     -- This can either be bilaterally
  802.                     -- used name or a name that is
  803.                     -- registered somewhere (IANA?).
  804.                     -- The idea is to compress the
  805.                     -- data so that the transport takes
  806.                     -- less time. A good candidate is
  807.                     -- GNU-zip.
  808.         
  809.         <MAX-line>    ::=
  810.  
  811.  
  812. Kaittola                 Expires: January, 1994                [Page 14]
  813.  
  814. DRAFT                  File distribution - dialog                  DRAFT
  815.  
  816.  
  817.             MAXSIZE: <SP>* <d>1* <CR>
  818.                      -- This is the maximum size (in kb)
  819.                      -- of data one message may contain.
  820.                     -- a <CR> is counted as two bytes.
  821.                     -- If it's value is zero then there
  822.                     -- is no maximum size set. A server
  823.                     -- may use smaller limit that what
  824.                     -- is set in here, but it must not
  825.                     -- send a message with data part
  826.                     -- bigger than the requested maximum
  827.                     -- size. (The actual size of the
  828.                     -- message is more than the size of
  829.                     -- data. However, the size of the
  830.                     -- data is a dominant factor.)
  831.         
  832.         <K-line>    ::=        -- KEY line
  833.             KEY: <SP>* <key> <CR>
  834.         
  835.         <key>            ::=        -- signature key
  836.             <ldh>10*20
  837.         
  838.         <E-line>    ::=        -- SERIAL line
  839.             SERIAL: <SP>* <serial> <CR>
  840.         
  841.         <serial>    ::=        -- serial number
  842.             <d>1*10            -- Serial number consists of
  843.                         -- up to ten digits. It is
  844.                         -- intended that whenever a
  845.                         -- new request is sent the
  846.                         -- serial number is
  847.                         -- incremented by one.
  848.                         -- However, implementation
  849.                         -- may choose to use it
  850.                         -- differently.
  851.         
  852.         
  853. 4.3. Data
  854.         
  855.         The distributor sends the file(s) in a DATA message to the
  856.         recipient.
  857.         
  858.         For example:
  859.         
  860.         DATA:    FILE TXT COSINE-MHS/mapping-1
  861.         VERSION:    121303-170393
  862.         PATH:    <cosine-server@cosine-mhs.switch.ch>
  863.         COMPRESSION: NONE
  864.         CHECK:    123 USED
  865.         PART: 1 of 3
  866.         ---------- start cosine-mhs/mapping-1 ----------
  867.         <data>
  868.  
  869.  
  870. Kaittola                 Expires: January, 1994                [Page 15]
  871.  
  872. DRAFT                  File distribution - dialog                  DRAFT
  873.  
  874.  
  875.         ----------  end cosine-mhs/mapping-1  ----------
  876.         IAM:    <cosine-server@cosine-mhs.switch.ch>
  877.         KEY:    1234567890abcdefghij
  878.         SERIAL:    123
  879.         REPLY:    + Positive
  880.         
  881.         Formal definition:
  882.         
  883.         <D-msg>        ::=    -- DATA message
  884.             ( <D-line>        -- If this block is missing
  885.               <V-line>        -- then reply at K-line must
  886.               <P-line>1*        -- be set to negative.
  887.               <CMP-line>
  888.               <C-line>
  889.               <PART-line>
  890.               <start-separator> <file> <end-separator> )*
  891.             <IAM-line>
  892.             <K-line>
  893.             <E-line>
  894.             <R-line>
  895.         
  896.         <D-line>    ::=        -- DATA line
  897.             DATA: <SP>* ( FILE ( TXT | BINARY ) | CMD | LIST [RECURSIVE] )
  898.             <SP>* <file-name> <CR>
  899.         
  900.         <P-line>    ::=        -- PATH line
  901.             PATH: <SP>* ( IGNORE | <addr> ) <CR>
  902.                     -- There can be more than one PATH
  903.                     -- line. Basically, IAM-line for
  904.                     -- every node that the message have
  905.                     -- passed through should be listed.
  906.                     -- New line will always be placed
  907.                     -- before any other PATH line.
  908.                     -- If there are more than one PTH
  909.                     -- line the last line can contain
  910.                     -- a keyword "IGNORE", which means
  911.                     -- that one or more PATH line has
  912.                     -- been removed. This is intended
  913.                     -- for situations where the actual
  914.                     -- path a file has taken isn't so
  915.                     -- important to know.
  916.         
  917.         <PART-line>    ::=
  918.             PART: <SP>* <d>1* <SP>*of <SP>*<d>1* <CR>
  919.                         -- This is needed for multipart
  920.                     -- messages. (Multipart messages
  921.                     -- are needed if such a big file
  922.                     -- has been requested that it can't
  923.                     -- be sent in one message.) If
  924.                     -- message isn't multipart then
  925.                     -- PART: 1 of 1 is used.
  926.  
  927.  
  928. Kaittola                 Expires: January, 1994                [Page 16]
  929.  
  930. DRAFT                  File distribution - dialog                  DRAFT
  931.  
  932.  
  933.         
  934.         <start-separator> ::=
  935.             ---------- <S> start <S> <file-name> <S> ----------
  936.                         -- Although spacing is defined to be
  937.                     -- strictly like this, when
  938.                     -- receiving a message the amount of
  939.                     -- spaces must be treated as being
  940.                     -- insignificant. The same is true
  941.                     -- for the <end-separator> as well.
  942.         
  943.         <file>        ::=
  944.                     -- Base64 encoded file to be
  945.                     -- transmitted; As Base 64 doesn't
  946.                     -- use a hyphen there is no danger
  947.                     -- for confusion.
  948.                            -- In addition to Base64 a Hamming
  949.                            -- coding can be used to calculate
  950.                            -- checksums for each line. The
  951.                     -- coding is adjusted to notice if
  952.                     -- lines are duplicated or lost.
  953.         
  954.         <end-separator>    ::=
  955.             ---------- <S> <S> end <S> <file-name> <S> <S> ----------
  956.                        -- Look at the comment for the
  957.                        -- <start-separator>.
  958.         
  959.         <C-line>    ::=
  960.             CHECK: <SP>* <check-sum> ( USED | NONE ) <CR>
  961.                         -- If USED then Hamming coding has
  962.                     -- been used to calculate a checksum
  963.                     -- for every line of data.
  964.         
  965.         <check-sum>    ::=
  966.                     -- Checksum is simply the number of
  967.                     -- data lines (or 33+2 bytes blocks
  968.                     -- if Hamming coding is used).
  969.                     -- It is used to find out if there
  970.                     -- are any lines missing (or
  971.                     -- duplicated). If Hamming coding
  972.                     -- is used, this is used to detect
  973.                     -- blocks that are missing from the
  974.                     -- end.
  975.         
  976.         <R-line>    ::=    -- REPLY line
  977.             REPLY: <SP>* <reply> <SP>* <explanation> <CR>
  978.         
  979.         <reply>        ::=    -- Status of reply
  980.                 +|-    -- Plus or minus, positive or
  981.                     -- negative
  982.         
  983.         <explanation>    ::=    -- A free-form explanation, can be
  984.  
  985.  
  986. Kaittola                 Expires: January, 1994                [Page 17]
  987.  
  988. DRAFT                  File distribution - dialog                  DRAFT
  989.  
  990.  
  991.             (<ldh>|<SP>)*    -- long if line continuation is
  992.                     -- used. If it contains the string
  993.                     -- "\n" it is to be understood as
  994.                     -- an end of line.
  995.         
  996.         On of the following explanations must be present at
  997.         <explanation>:
  998.         
  999.         - Positive. Requested file(s) are sent.
  1000.         
  1001.         - Validition failure. A file may or may not exist locally,
  1002.           but the recipient is not served.
  1003.         
  1004.         - File doesn't exist. The requested file is not available.
  1005.         
  1006.         - Too new version. File exists, but version being requested
  1007.           is too new (doesn't exist).
  1008.         
  1009.         - Version not available. Newer version exists locally, but
  1010.           requested version doesn't.
  1011.         
  1012.         - Incorrect request. Something else went wrong.
  1013.         
  1014.         If the requested files are sent the reply status is set to
  1015.         positive, othervise it is set to negative. Answer will
  1016.         contain the information specified above (for logging
  1017.         purposes) and possibly some locally defined explanation.
  1018.         For every request that fail a separate message is required.
  1019.         
  1020.         
  1021. 4.4 List
  1022.         
  1023.         The client requests a listing of files by sending a LIST
  1024.         message. An example follows.
  1025.         
  1026.         # Directory
  1027.         LIST:     COSINE-MHS/ TMP/listing
  1028.         # Data compression (if used)
  1029.         COMPRESSION: NONE
  1030.         # Max size of data in reply
  1031.         MAXSIZE: 60
  1032.         # RFC-addr between a pair of "<>", OR-addr using /-notation.
  1033.         IAM:    <cosine-server@cosine-mhs.switch.ch>
  1034.         # Key
  1035.         KEY:    1234567890abcdefghij
  1036.         # Serial
  1037.         SERIAL:    123
  1038.         
  1039.         The reply to a LIST message is not an IHAVE message. The
  1040.         reply is generally not intended to be used to request
  1041.         files, although it could be used in that way, too.
  1042.  
  1043.  
  1044. Kaittola                 Expires: January, 1994                [Page 18]
  1045.  
  1046. DRAFT                  File distribution - dialog                  DRAFT
  1047.  
  1048.  
  1049.         
  1050.         Formal definition
  1051.         
  1052.         <L-msg> ::=        -- LIST message
  1053.             <L-line>
  1054.             <CMP-line>
  1055.             <MAX-line>
  1056.             <IAM-line>
  1057.             <K-line>
  1058.             <E-line>
  1059.         
  1060.         <L-line> ::=
  1061.             LIST: <directory> <SP>1* <file-name> 
  1062.             [<SP>1* RECURSIVE] <CR>
  1063.                            -- Request either a list of files in
  1064.                            -- a directory or a recursive
  1065.                     -- listing. The result is sent back
  1066.                     -- in <file-name>.
  1067.         
  1068.         
  1069. 4.5. Ping
  1070.         
  1071.         A ping message is used to test connectivity to the server.
  1072.         The server is expected to reply with a PONG message. For
  1073.         example:
  1074.         
  1075.         PING
  1076.         IAM: <tester@funet.fi>
  1077.         KEY: 1234567890absdefghij
  1078.         SERIAL: 123
  1079.         
  1080.         Formal definition:
  1081.         
  1082.         <PING-msg>    ::=
  1083.             <PING-line>
  1084.             <IAM-line>
  1085.             <K-line>
  1086.             <E-line>
  1087.         
  1088.         <PING-line>     ::=
  1089.             PING <CR>
  1090.         
  1091.         
  1092. 4.6. Pong
  1093.         
  1094.         A pong message is a reply to a ping message. For example:
  1095.         
  1096.         PONG
  1097.         IAM:    <cosine-server@cosine-mhs.switch.ch>
  1098.         KEY:    1234567890absdefghij
  1099.         SERIAL:    123
  1100.  
  1101.  
  1102. Kaittola                 Expires: January, 1994                [Page 19]
  1103.  
  1104. DRAFT                  File distribution - dialog                  DRAFT
  1105.  
  1106.  
  1107.         GREETING:    Greetings from MHS coordination server!
  1108.         
  1109.         Formal definition:
  1110.         
  1111.         <PONG-msg>    ::=
  1112.             <PONG-line>
  1113.             <IAM-line>
  1114.             <K-line>
  1115.             <E-line>
  1116.             <G-line>
  1117.         
  1118.         <PONG-line>     ::=
  1119.             PONG <CR>
  1120.         
  1121.         <G-line>     ::=
  1122.             GREETING: <SP>* <any>* <CR>
  1123.                     -- Greeting is an informal text
  1124.                     -- that can be presented to the
  1125.                     -- human that uses the ping client
  1126.                     -- to test the server.
  1127.                     -- Line continuation is to be used
  1128.                     -- if all of the text can't be fit
  1129.                     -- into one line. Use "\n" to
  1130.                     -- represent a line break.
  1131.         
  1132.         
  1133. 4.7. Contents of data
  1134.         
  1135.         Normally data message carries a (set of) file(s) that can be
  1136.         either text files or binary files. These are encoded using
  1137.         Base64 as defined in [RFC-1341] (pages 17-19).
  1138.         
  1139.         Commands and listings are also carried as normal files.
  1140.         All these cases will be distinquished based on <D-line>
  1141.         where keywords "FILE", "CMD" and "LIST" are used. A keyword
  1142.         "FILE" will be folloved by "TXT" or "BINARY" to describe the
  1143.         type of the file.
  1144.         
  1145.         A command file could look like this:
  1146.         
  1147.         SOURCE: <cosine-server@cosine-mhs.switch.ch> (MHS server)
  1148.         APPROVED-BY: <staff@cosine-mhs.switch.ch> (MHS team)
  1149.         CREATE: cosine-mhs/mapping-notes-1
  1150.         CREATE: cosine-mhs/mapping-notes-2
  1151.         DELETE: cosine-mhs/mapping-notes
  1152.         
  1153.         Formally this can be defined like this:
  1154.         
  1155.         <CMD-file> ::=
  1156.             <SOURCE-line>
  1157.             <A-line>1*
  1158.  
  1159.  
  1160. Kaittola                 Expires: January, 1994                [Page 20]
  1161.  
  1162. DRAFT                  File distribution - dialog                  DRAFT
  1163.  
  1164.  
  1165.             <CMD-line>1*
  1166.         
  1167.         <SOURCE-line> ::=
  1168.             SOURCE: <SP>* <addr> <SP>* <(> <explanation> <)>
  1169.             <CR>
  1170.                     -- This is the source of this
  1171.                     -- command file. It includes the
  1172.                     -- e-mail address of the source as
  1173.                     -- well as a human readable name for
  1174.                     -- it.
  1175.         
  1176.         <explanation> ::=    -- This is the human readable name
  1177.             <any>1*        -- associated with an e-mail
  1178.                     -- address.
  1179.         
  1180.         <A-line> ::=
  1181.             APPROVED-BY: <SP>* <addr> <SP>* <(> <explanation>
  1182.             <)> <CR>    -- The syntax is very much like in
  1183.                     -- <SOURCE-line>. However, they have
  1184.                     -- different semantic meanings.
  1185.                     -- A <SOURCE-line> tells who
  1186.                     -- originally created the command.
  1187.                     -- A new <A-line> is created every
  1188.                     -- time a message is checked by
  1189.                     -- intermediate nodes. Checking (by
  1190.                     -- human staff) is mandatory when
  1191.                     -- a command for creating or
  1192.                     -- deleting a file is sent. It is
  1193.                     -- strongly suggested that checking
  1194.                     -- will be carried out whenever
  1195.                     -- commands are executed. Transit
  1196.                     -- nodes can do checking but they
  1197.                     -- don't have to.
  1198.         
  1199.         <CMD-line> ::=
  1200.             CREATE | ( DELETE [ <SP>1 RECURSIVE ] ) :
  1201.             ( FILE <SP>* <file-name> ) | ( DIR <SP>*
  1202.             <directory> ) <CR>
  1203.                         -- CREATE is used to create either
  1204.                     -- a new file or a new directory.
  1205.                     -- DELETE is used to delete a file
  1206.                     -- or a directory. Unless RECURSIVE
  1207.                     -- is specified a directory to be
  1208.                     -- deleted must be empty.
  1209.         
  1210.         When sending a listing in a file it looks either like this
  1211.         (normal listing):
  1212.         
  1213.         [cosine-mhs/mapings]
  1214.         [FILE] mapping-1
  1215.         [FILE] mapping-2
  1216.  
  1217.  
  1218. Kaittola                 Expires: January, 1994                [Page 21]
  1219.  
  1220. DRAFT                  File distribution - dialog                  DRAFT
  1221.  
  1222.  
  1223.         [FILE] mapping-gate
  1224.         [DIR]  old
  1225.         [FILE] info
  1226.         [DIR]  tools
  1227.         
  1228.         Or it looks like this (recursive listing)
  1229.         
  1230.         [cosine-mhs/mapings]
  1231.         [FILE] mapping-1
  1232.         [FILE] mapping-2
  1233.         [FILE] mapping-gate
  1234.         [DIR]  old
  1235.           [FILE] mapping-1
  1236.           [FILE] mapping-2
  1237.           [FILE] mapping-gate
  1238.         [RID]
  1239.         [FILE] info
  1240.         [DIR]  tools
  1241.           [FILE] generate
  1242.           [DIR]  data
  1243.             [FILE] countries
  1244.           [RID]
  1245.           [FILE] check
  1246.         [RID]
  1247.         
  1248.         As can be seen, the level of indentation is used to visually
  1249.         indicate which files belong to which directory.
  1250.         
  1251.         Formal definition is like this:
  1252.         
  1253.         <LISTING-file> ::=
  1254.             <N-line>
  1255.             <LIST-line>*
  1256.         
  1257.         <LIST-line> ::=
  1258.             (<S> <S>) *
  1259.             ( <[> ( FILE | DIR ) <]> <SP>* <file-name> ) |
  1260.             ( <[> RID <]> ) <CR>
  1261.                     -- Spaces at the beginning of lines
  1262.                     -- are used to denote the directory
  1263.                     -- structure. They are not
  1264.                     -- interpreted while parsing a
  1265.                     -- message but used to help a human
  1266.                     -- reader understand the structure.
  1267.                     -- A directory is started with a
  1268.                     -- [DIR] and closed with a [RID].
  1269.                     -- A sophisticated user agent could
  1270.                     -- hide [RID] lines from a human, as
  1271.                     -- they are only intended to ease
  1272.                     -- the parsing. [RID]-lines are not
  1273.                     -- needed for non-recursive message.
  1274.  
  1275.  
  1276. Kaittola                 Expires: January, 1994                [Page 22]
  1277.  
  1278. DRAFT                  File distribution - dialog                  DRAFT
  1279.  
  1280.  
  1281. 5. Coding and checksums
  1282.         
  1283.         When data is transmitted it is always encoded, either using
  1284.         normal Base64 as defined in [RFC-1341], or using modified
  1285.         Base64.
  1286.         
  1287.         When using the normal Base64 a line lenght of 76 is to be
  1288.         used when sending a message. However, when receiving a
  1289.         message an arbitrary (and possibly varying) line lenght is
  1290.         to be accepted.
  1291.         
  1292.         The modified Base64 is actually a mixture of Base64 and a
  1293.         Hamming code. The Hamming coding is used for error
  1294.         detection.  It could be used for error correction as well,
  1295.         but it is expected that errors are rare but severe, so when
  1296.         an error is found the data is requested to be sent again.
  1297.         
  1298.         
  1299. 5.1. Some background
  1300.         
  1301.         Using only the normal Base64 is defined well enough in
  1302.         [RFC-1341].
  1303.         
  1304.         The checksum code used is a (91,88) base-9 Hamming
  1305.         code. This means that three base-9 symbols are generated for
  1306.         every 88 base-9 symbols. One base-9 symbol can fully
  1307.         represent three bits, thus 33 bytes are processed to
  1308.         generate the checksum. Coding those 33 bytes to Base64
  1309.         symbols makes 44 symbols. Checksum (3 base-9 symbols) is
  1310.         represented with 2 Base64 symbols, thus encoding 33 bytes of
  1311.         original data totals up to a block of 46 Base64 symbols. If
  1312.         the checksum is used a line length of 46 is to be used when
  1313.         encoding data. As usual, any line lenght is to be accepted
  1314.         when decoding data.
  1315.         
  1316.         All arithmetics are performed in remainder class 9. An
  1317.         analysis of reminder class 9 is not provided here, but for
  1318.         example
  1319.         
  1320.         2 * 7 = (14 modulo 9) = 5
  1321.         8 + 1 = (9 modulo 9)  = 0
  1322.         
  1323.         The input stream is processed 33 bytes at a time. If there
  1324.         are less than 33 bytes left to process the block is
  1325.         zero-padded for the checksum calculation. This padding is
  1326.         internal to the checksum calculation.
  1327.         
  1328.         
  1329. 5.2. Calculating the checksum
  1330.         
  1331.         When calculating the checksum the data is handled in
  1332.  
  1333.  
  1334. Kaittola                 Expires: January, 1994                [Page 23]
  1335.  
  1336. DRAFT                  File distribution - dialog                  DRAFT
  1337.  
  1338.  
  1339.         three-byte (or 24 bits) groups, like this:
  1340.         
  1341.         Bytes    000000001111111122222222
  1342.         Base64    000000111111222222333333
  1343.         Base-9  777666555444333222111000
  1344.         
  1345.         Three bytes can be split into four Base64 or eight three-bit
  1346.         groups that are interprented as base-9 symbols. 33 bytes
  1347.         generate 11 3-byte groups, 44 base64 symbols and 88 base-9
  1348.         symbols.
  1349.         
  1350.         The checksum calculation is a simple matrix
  1351.         multiplication. The 88-element base-9 vector is
  1352.         multiplicated with a 3x88-element matrix and the result is a
  1353.         3-element vector. Because all calculations are done in the
  1354.         remainder class 9, only values from zero to eight are
  1355.         present in the matrix and the results will also be from zero
  1356.         to eight. The reversed order of the base-9 symbols is
  1357.         selected to help to develop as efficient implementation as
  1358.         possible.
  1359.         
  1360.         To generate a checksum vector c one multiplies data vector d
  1361.         with a generator matrix G this way:
  1362.         
  1363.         c = d * G
  1364.         
  1365.         The checksum vector c is then converted into two Base64
  1366.         symbols as follows:
  1367.         
  1368.         Checksum   000011112222 (byte positions)
  1369.         Base64       000000111111
  1370.         
  1371.         Four bits are needed to represent one base-9 symbol. Three
  1372.         base-9 symbols total up to 12 bits, which can be represented
  1373.         in two Base64 symbols.
  1374.         
  1375.         The generator matrix G is:
  1376.         
  1377.         Rows 1-22       Rows 23-44      Rows 45-66      Rows 67-88
  1378.         
  1379.         0 1 1           1 1 4           1 3 8           1 6 3
  1380.         0 1 2           1 1 5           1 4 0           1 6 4
  1381.         0 1 3           1 1 6           1 4 1           1 6 5
  1382.         0 1 4           1 1 7           1 4 2           1 6 6
  1383.         0 1 5           1 1 8           1 4 3           1 6 7
  1384.         0 1 6           1 2 0           1 4 4           1 6 8
  1385.         0 1 7           1 2 1           1 4 5           1 7 0
  1386.         0 1 8           1 2 2           1 4 6           1 7 1
  1387.         0 3 1           1 2 3           1 4 7           1 7 2
  1388.         0 3 2           1 2 4           1 4 8           1 7 3
  1389.         1 0 1           1 2 5           1 5 0           1 7 4
  1390.  
  1391.  
  1392. Kaittola                 Expires: January, 1994                [Page 24]
  1393.  
  1394. DRAFT                  File distribution - dialog                  DRAFT
  1395.  
  1396.  
  1397.         1 0 2           1 2 6           1 5 1           1 7 5
  1398.         1 0 3           1 2 7           1 5 2           1 7 6
  1399.         1 0 4           1 2 8           1 5 3           1 7 7
  1400.         1 0 5           1 3 0           1 5 4           1 7 8
  1401.         1 0 6           1 3 1           1 5 5           1 8 0
  1402.         1 0 7           1 3 2           1 5 6           1 8 1
  1403.         1 0 8           1 3 3           1 5 7           1 8 2
  1404.         1 1 0           1 3 4           1 5 8           1 8 3
  1405.         1 1 1           1 3 5           1 6 0           1 8 4
  1406.         1 1 2           1 3 6           1 6 1           1 8 5
  1407.         1 1 3           1 3 7           1 6 2           1 8 6
  1408.         
  1409.         However, calculating the checksum in this way is only the
  1410.         first stage: at a second stage the checksum of the previous
  1411.         line (or a zero-vector if the first line is being processed)
  1412.         is added to the checksum vector. This addition is done in
  1413.         reminder class 9 as a vector operation, so there won't be
  1414.         any problems with an over-flow.
  1415.         
  1416.         The <check-sum> that is present in the <C-line> is the
  1417.         number of the 33 bytes blocks, or (if no Hamming coding is
  1418.         used) the number of Base64 lines.
  1419.         
  1420.         
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450. Kaittola                 Expires: January, 1994                [Page 25]
  1451.  
  1452. DRAFT                  File distribution - dialog                  DRAFT
  1453.  
  1454.  
  1455. 6. Security consideratins
  1456.         
  1457.         Security is based on keys that are sent with the request and
  1458.         copied in a reply. This gives a protection against forged
  1459.         messages. It doesn't work if an ethernet is tapped or some
  1460.         relaying machine is cracked.  However, this is considered to
  1461.         be such an extreme situation that such a cracker could in
  1462.         any case cause a great deal of trouble.
  1463.         
  1464.         
  1465. References
  1466.         
  1467.         [RFC-952]    RFC 952 (DOD Internet Host Table
  1468.                 Specification)
  1469.         [RFC-1123]    RFC 1123 (Requirements for Internet Hosts --
  1470.                 Application and Support)
  1471.         [RFC-1341]    RFC 1341 (MIME  (Multipurpose Internet Mail
  1472.                 Extensions))
  1473.         [DST-STRUCTURE]    Mail based file distribution - Part 2:
  1474.                 Over-all structure
  1475.         [DST-MHS]    One more companion document to be written
  1476.                 (informational)
  1477.         
  1478.         
  1479. Acknowledgements
  1480.         
  1481.         Various peoples have contributed on this document. It is
  1482.         impossible to list everyone here. However, I'd like to give
  1483.         special thanks to the following:
  1484.         
  1485.         Urs Eppenberger, Allan Cargille, Harald Tveit Alvestrand,
  1486.         Paul Andre Pays and Jim Romaquera from RARE WG1 / RARE
  1487.         WG-MSG / COSINE MHS managers / IETF X.400 ops have
  1488.         contributed and kept me going.
  1489.         
  1490.         Pasi Ojala wrote the first implementation while I wrote this
  1491.         paper. He also suggested many improvements. He developed the
  1492.         approach used in Hamming coding.
  1493.         
  1494.         Keijo Ruohonen helped with the Hamming coding.
  1495.         
  1496.         
  1497. Author's address
  1498.         
  1499.         Marko Kaittola
  1500.         FUNET
  1501.         c/o Tampere University of Technology
  1502.         Software Systems Laboratory
  1503.         P.O. Box 553
  1504.         SF-33101 Tampere
  1505.         Finland
  1506.  
  1507.  
  1508. Kaittola                 Expires: January, 1994                [Page 26]
  1509.  
  1510. DRAFT                  File distribution - dialog                  DRAFT
  1511.  
  1512.  
  1513.         
  1514.         E-mail: Marko.Kaittola@funet.fi
  1515.                 G=Marko; S=Kaittola; O=funet; A=fumail; C=fi;
  1516.         
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566. Kaittola                 Expires: January, 1994                [Page 27]
  1567.  
  1568. DRAFT                  File distribution - dialog                  DRAFT
  1569.  
  1570.  
  1571. Appendix A: BNF summary - initial parsing
  1572.         
  1573.         <comment>    ::=
  1574.             # <any>* <CR>    -- A line starting with a "#" is
  1575.                     -- a comment.
  1576.         
  1577.         <folded-line>    ::=
  1578.             <any>1* ( \ <CR> <SP>1* <any>1* )1* <CR>
  1579.                        -- Note that there are no
  1580.                        -- insignificant spaces before
  1581.                               -- the backslash. If there is a space
  1582.                               -- it is significant. Spaces in front 
  1583.                               -- of the continuation line(s) are 
  1584.                        -- insignificant and will be removed
  1585.                        -- while putting the physical lines
  1586.                        -- together.
  1587.         
  1588.         
  1589.         
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624. Kaittola                 Expires: January, 1994                [Page 28]
  1625.  
  1626. DRAFT                  File distribution - dialog                  DRAFT
  1627.  
  1628.  
  1629. Appendix B: BNF summary - message structure
  1630.         
  1631.         <addr>        ::=
  1632.             <RFC-addr> | <OR-addr> | ( <RFC-addr> <SP>* <OR-addr> )
  1633.                     -- Also some other kind of address
  1634.                     -- could be used. However, it must
  1635.                     -- not start or end either with "//"
  1636.                     -- nor with "<>".
  1637.                     -- Listing both RFC-address and OR
  1638.                     -- address might make sense as the
  1639.                     -- sender doesn't always know
  1640.                     -- which one is more appropriate
  1641.                     -- form.
  1642.         
  1643.         <C-line>    ::=
  1644.             CHECK: <SP>* <check-sum> ( USED | NONE ) <CR>
  1645.                         -- If USED then Hamming coding has
  1646.                     -- been used to calculate a checksum
  1647.                     -- for every line of data.
  1648.         
  1649.         <check-sum>    ::=
  1650.                     -- Checksum is simply the number of
  1651.                     -- data lines (or 33+2 bytes blocks
  1652.                     -- if Hamming coding is used).
  1653.                     -- It is used to find out if there
  1654.                     -- are any lines missing (or
  1655.                     -- duplicated). If Hamming coding
  1656.                     -- is used, this is used to detect
  1657.                     -- blocks that are missing from the
  1658.                     -- end.
  1659.         
  1660.         <CMP-line>    ::=
  1661.             COMPRESSION: <SP>* NONE | 
  1662.                      ( IS <SP>* <compression> ) |
  1663.                      ( CAN <SP>* <compression> [ ; <SP>*
  1664.                                      <compression> ] )
  1665.             <CR>        -- In sendme-message compression can
  1666.                     -- be either NONE or it can be a
  1667.                     -- list of possible compressions
  1668.                     -- (CAN alternative). In data-
  1669.                     -- message it can be either NONE
  1670.                     -- or the name of used compression
  1671.                     -- (IS-alternative). The idea is
  1672.                     -- that when a message is being
  1673.                     -- requested it is possible to
  1674.                     -- specify all of the possible
  1675.                     -- compressions. The server may
  1676.                     -- pick one of them, or it may use
  1677.                     -- no compression at all.
  1678.         
  1679.         
  1680.  
  1681.  
  1682. Kaittola                 Expires: January, 1994                [Page 29]
  1683.  
  1684. DRAFT                  File distribution - dialog                  DRAFT
  1685.  
  1686.  
  1687.         <compression>    ::=
  1688.             <ldh>1*15    -- The name of the used compression.
  1689.                     -- This can either be bilaterally
  1690.                     -- used name or a name that is
  1691.                     -- registered somewhere (IANA?).
  1692.                     -- The idea is to compress the
  1693.                     -- data so that the transport takes
  1694.                     -- less time. A good candidate is
  1695.                     -- GNU-zip.
  1696.         
  1697.         <D-line>    ::=        -- DATA line
  1698.             DATA: <SP>* ( FILE ( TXT | BINARY ) | CMD | LIST [RECURSIVE] )
  1699.             <SP>* <file-name> <CR>
  1700.         
  1701.         <D-msg>        ::=    -- DATA message
  1702.             ( <D-line>        -- If this block is missing
  1703.               <V-line>        -- then reply at K-line must
  1704.               <P-line>1*        -- be set to negative.
  1705.               <CMP-line>
  1706.               <C-line>
  1707.               <PART-line>
  1708.               <start-separator> <file> <end-separator> )*
  1709.             <IAM-line>
  1710.             <K-line>
  1711.             <E-line>
  1712.             <R-line>
  1713.         
  1714.         <directory>    ::=
  1715.             <l> (<ldh>|_)*14 /
  1716.                     -- for example: "COSINE-MHS/"
  1717.                     -- This is case-sensitive, but it
  1718.                     -- is suggested that capital letters
  1719.                     -- are used for a directory whenever
  1720.                     -- possible. A special directory
  1721.                     -- name "Cmds" (and it's
  1722.                     -- subdirectories) are reserved for
  1723.                     -- commands. It is explicitly
  1724.                     -- forbidden to store any (normal)
  1725.                     -- files there.
  1726.         
  1727.         <E-line>    ::=        -- SERIAL line
  1728.             SERIAL: <SP>* <serial> <CR>
  1729.         
  1730.         <end-separator>    ::=
  1731.             ---------- <S> <S> end <S> <file-name> <S> <S> ----------
  1732.                        -- Look at the comment for the
  1733.                        -- <start-separator>.
  1734.         
  1735.         <explanation>    ::=    -- A free-form explanation, can be
  1736.             (<ldh>|<SP>)*    -- long if line continuation is
  1737.                     -- used. If it contains the string
  1738.  
  1739.  
  1740. Kaittola                 Expires: January, 1994                [Page 30]
  1741.  
  1742. DRAFT                  File distribution - dialog                  DRAFT
  1743.  
  1744.  
  1745.                     -- "\n" it is to be understood as
  1746.                     -- an end of line.
  1747.         
  1748.         <file>        ::=
  1749.                     -- Base64 encoded file to be
  1750.                     -- transmitted; As Base 64 doesn't
  1751.                     -- use a hyphen there is no danger
  1752.                     -- for confusion.
  1753.                            -- In addition to Base64 a Hamming
  1754.                            -- coding can be used to calculate
  1755.                            -- checksums for each line. The
  1756.                     -- coding is adjusted to notice if
  1757.                     -- lines are duplicated or lost.
  1758.         
  1759.         <file-name>    ::=
  1760.             <directory>* <filename>
  1761.                     -- File name is a symbolic name,
  1762.                     -- although it looks like a Unix
  1763.                     -- file name.
  1764.         
  1765.         <filename>    ::=
  1766.             <l> (<ldh>|_)*14 [ . ( <ldh> | _ )1*14 ]
  1767.                     -- For example: "mapping-1" or
  1768.                     -- "a_long_file.extension". This is
  1769.                     -- case-sensitive, but small
  1770.                     -- letters are suggested for a file
  1771.                     -- name whenever possible.
  1772.         
  1773.         <ftp-file>    ::=    -- The name of the file to be get
  1774.             <any>1*        -- using FTP. Even a semicolon may
  1775.                     -- be part of it.
  1776.         
  1777.         <FTP-line>    ::=
  1778.             FTP: <SP>* <host> : <ftp-file> <SP>* ; <SP>*
  1779.             <user> <SP>* ; <SP>* <pass> <CR>
  1780.                        -- FTP is one more option for getting
  1781.                        -- a file. This line doesn't have to
  1782.                        -- be present. Even if it is present
  1783.                        -- also normal method (mail) must be
  1784.                        -- available.
  1785.         
  1786.         <G-line>     ::=
  1787.             GREETING: <SP>* <any>* <CR>
  1788.                     -- Greeting is an informal text
  1789.                     -- that can be presented to the
  1790.                     -- human that uses the ping client
  1791.                     -- to test the server.
  1792.                     -- Line continuation is to be used
  1793.                     -- if all of the text can't be fit
  1794.                     -- into one line. Use "\n" to
  1795.                     -- represent a line break.
  1796.  
  1797.  
  1798. Kaittola                 Expires: January, 1994                [Page 31]
  1799.  
  1800. DRAFT                  File distribution - dialog                  DRAFT
  1801.  
  1802.  
  1803.         
  1804.         <host>            ::=
  1805.             ( <host-component> ( . <host-component> )1* ) |
  1806.             <[> <d>1*3 ( . <d>1*3 )3*3 <]>
  1807.                     -- Look at [RFC-952] and
  1808.                     -- [RFC-1123] to see the source of
  1809.                     -- this definition.
  1810.         
  1811.         <host-component> ::=
  1812.             ( <l> | <d> ) <ldh>1*
  1813.         
  1814.         <I-line>    ::=    -- Commands are given in a special
  1815.                     -- file 
  1816.             IHAVE: <SP>* ( FILE ( TXT | BINARY ) | CMD ) <SP>*
  1817.             <file-name> <CR>
  1818.         
  1819.         <I-msg>        ::=    -- IHAVE message
  1820.             ( <I-line> <V-line> [<FTP-line>] )1*
  1821.             <IAM-line>
  1822.         
  1823.         <IAM-line>    ::=
  1824.             IAM: <SP>* <addr> <CR>
  1825.         
  1826.         <K-line>    ::=        -- KEY line
  1827.             KEY: <SP>* <key> <CR>
  1828.         
  1829.         <key>            ::=        -- signature key
  1830.             <ldh>10*20
  1831.         
  1832.         <L-line> ::=
  1833.             LIST: <directory> <SP>1* <file-name> 
  1834.             [<SP>1* RECURSIVE] <CR>
  1835.                            -- Request either a list of files in
  1836.                            -- a directory or a recursive
  1837.                     -- listing. The result is sent back
  1838.                     -- in <file-name>.
  1839.         
  1840.         <L-msg> ::=        -- LIST message
  1841.             <L-line>
  1842.             <CMP-line>
  1843.             <MAX-line>
  1844.             <IAM-line>
  1845.             <K-line>
  1846.             <E-line>
  1847.         
  1848.         <MAX-line>    ::=
  1849.             MAXSIZE: <SP>* <d>1* <CR>
  1850.                      -- This is the maximum size (in kb)
  1851.                      -- of data one message may contain.
  1852.                     -- a <CR> is counted as two bytes.
  1853.                     -- If it's value is zero then there
  1854.  
  1855.  
  1856. Kaittola                 Expires: January, 1994                [Page 32]
  1857.  
  1858. DRAFT                  File distribution - dialog                  DRAFT
  1859.  
  1860.  
  1861.                     -- is no maximum size set. A server
  1862.                     -- may use smaller limit that what
  1863.                     -- is set in here, but it must not
  1864.                     -- send a message with data part
  1865.                     -- bigger than the requested maximum
  1866.                     -- size. (The actual size of the
  1867.                     -- message is more than the size of
  1868.                     -- data. However, the size of the
  1869.                     -- data is a dominant factor.)
  1870.         
  1871.         <OR-addr>    ::=
  1872.                     -- Normal valid OR address using
  1873.                     -- "/ notation" not enclosed in
  1874.                     -- "<>" pair.
  1875.         
  1876.         <P-line>    ::=        -- PATH line
  1877.             PATH: <SP>* ( IGNORE | <addr> ) <CR>
  1878.                     -- There can be more than one PATH
  1879.                     -- line. Basically, IAM-line for
  1880.                     -- every node that the message have
  1881.                     -- passed through should be listed.
  1882.                     -- New line will always be placed
  1883.                     -- before any other PATH line.
  1884.                     -- If there are more than one PTH
  1885.                     -- line the last line can contain
  1886.                     -- a keyword "IGNORE", which means
  1887.                     -- that one or more PATH line has
  1888.                     -- been removed. This is intended
  1889.                     -- for situations where the actual
  1890.                     -- path a file has taken isn't so
  1891.                     -- important to know.
  1892.         
  1893.         <PART-line>    ::=
  1894.             PART: <SP>* <d>1* <SP>*of <SP>*<d>1* <CR>
  1895.                         -- This is needed for multipart
  1896.                     -- messages. (Multipart messages
  1897.                     -- are needed if such a big file
  1898.                     -- has been requested that it can't
  1899.                     -- be sent in one message.) If
  1900.                     -- message isn't multipart then
  1901.                     -- PART: 1 of 1 is used.
  1902.         
  1903.         <pass>        ::=    -- Password to be given.
  1904.             <any>1*        -- there are two reserved passwords:
  1905.                     -- "user@domain" is intended for
  1906.                     -- those anonymous FTP servers that
  1907.                     -- require a password consisting of
  1908.                     -- real username and domainname to
  1909.                     -- be used. It should be replased
  1910.                     -- with actual data. "SECRET" means
  1911.                     -- that password has to be known by
  1912.  
  1913.  
  1914. Kaittola                 Expires: January, 1994                [Page 33]
  1915.  
  1916. DRAFT                  File distribution - dialog                  DRAFT
  1917.  
  1918.  
  1919.                     -- some other means.
  1920.         
  1921.         <PING-line>     ::=
  1922.             PING <CR>
  1923.         
  1924.         <PING-msg>    ::=
  1925.             <PING-line>
  1926.             <IAM-line>
  1927.             <K-line>
  1928.             <E-line>
  1929.         
  1930.         <PONG-line>     ::=
  1931.             PONG <CR>
  1932.         
  1933.         <PONG-msg>    ::=
  1934.             <PONG-line>
  1935.             <IAM-line>
  1936.             <K-line>
  1937.             <E-line>
  1938.             <G-line>
  1939.         
  1940.         <R-line>    ::=    -- REPLY line
  1941.             REPLY: <SP>* <reply> <SP>* <explanation> <CR>
  1942.         
  1943.         <reply>        ::=    -- Status of reply
  1944.                 +|-    -- Plus or minus, positive or
  1945.                     -- negative
  1946.         
  1947.         <RFC-addr>    ::=
  1948.                     -- Normal, valid RFC-822 address
  1949.                     -- enclosed in "<>" pair.
  1950.         
  1951.         <S-line>    ::=        -- SENDME line
  1952.             SENDME: <SP>* ( FILE | CMD ) <CR>
  1953.             <SP>* <file-name> <CR>
  1954.         
  1955.         <S-msg>    ::=        -- SENDME message
  1956.             ( <S-line> <V-line> <CMP-line> )1*
  1957.             <MAX-line>
  1958.             <IAM-line>
  1959.             <K-line>
  1960.             <E-line>
  1961.         
  1962.         <serial>    ::=        -- serial number
  1963.             <d>1*10            -- Serial number consists of
  1964.                         -- up to ten digits. It is
  1965.                         -- intended that whenever a
  1966.                         -- new request is sent the
  1967.                         -- serial number is
  1968.                         -- incremented by one.
  1969.                         -- However, implementation
  1970.  
  1971.  
  1972. Kaittola                 Expires: January, 1994                [Page 34]
  1973.  
  1974. DRAFT                  File distribution - dialog                  DRAFT
  1975.  
  1976.  
  1977.                         -- may choose to use it
  1978.                         -- differently.
  1979.         
  1980.         <start-separator> ::=
  1981.             ---------- <S> start <S> <file-name> <S> ----------
  1982.                         -- Although spacing is defined to be
  1983.                     -- strictly like this, when
  1984.                     -- receiving a message the amount of
  1985.                     -- spaces must be treated as being
  1986.                     -- insignificant. The same is true
  1987.                     -- for the <end-separator> as well.
  1988.         
  1989.         <user>        ::=    -- Username to be given.
  1990.             <ld>1*
  1991.         
  1992.         <V-line>    ::=
  1993.             VERSION: <SP>* <vers-number> <CR>
  1994.         
  1995.         <vers-number>    ::=
  1996.             <d>6*6 - <d>6*6    -- This must be YYMMDD-hhmmss.
  1997.                     -- No timezone is specified. It is
  1998.                     -- assumed to be local to the
  1999.                     -- node that issues the version
  2000.                     -- number. 
  2001.         
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030. Kaittola                 Expires: January, 1994                [Page 35]
  2031.  
  2032. DRAFT                  File distribution - dialog                  DRAFT
  2033.  
  2034.  
  2035. Appendix C: BNF summary - data message parsing
  2036.         
  2037.         <A-line> ::=
  2038.             APPROVED-BY: <SP>* <addr> <SP>* <(> <explanation>
  2039.             <)> <CR>    -- The syntax is very much like in
  2040.                     -- <SOURCE-line>. However, they have
  2041.                     -- different semantic meanings.
  2042.                     -- A <SOURCE-line> tells who
  2043.                     -- originally created the command.
  2044.                     -- A new <A-line> is created every
  2045.                     -- time a message is checked by
  2046.                     -- intermediate nodes. Checking (by
  2047.                     -- human staff) is mandatory when
  2048.                     -- a command for creating or
  2049.                     -- deleting a file is sent. It is
  2050.                     -- strongly suggested that checking
  2051.                     -- will be carried out whenever
  2052.                     -- commands are executed. Transit
  2053.                     -- nodes can do checking but they
  2054.                     -- don't have to.
  2055.         
  2056.         <CMD-file> ::=
  2057.             <SOURCE-line>
  2058.             <A-line>1*
  2059.             <CMD-line>1*
  2060.         
  2061.         <CMD-line> ::=
  2062.             CREATE | ( DELETE [ <SP>1 RECURSIVE ] ) :
  2063.             ( FILE <SP>* <file-name> ) | ( DIR <SP>*
  2064.             <directory> ) <CR>
  2065.                         -- CREATE is used to create either
  2066.                     -- a new file or a new directory.
  2067.                     -- DELETE is used to delete a file
  2068.                     -- or a directory. Unless RECURSIVE
  2069.                     -- is specified a directory to be
  2070.                     -- deleted must be empty.
  2071.         
  2072.         <explanation> ::=    -- This is the human readable name
  2073.             <any>1*        -- associated with an e-mail
  2074.                     -- address.
  2075.         
  2076.         <LIST-line> ::=
  2077.             (<S> <S>) *
  2078.             ( <[> ( FILE | DIR ) <]> <SP>* <file-name> ) |
  2079.             ( <[> RID <]> ) <CR>
  2080.                     -- Spaces at the beginning of lines
  2081.                     -- are used to denote the directory
  2082.                     -- structure. They are not
  2083.                     -- interpreted while parsing a
  2084.                     -- message but used to help a human
  2085.                     -- reader understand the structure.
  2086.  
  2087.  
  2088. Kaittola                 Expires: January, 1994                [Page 36]
  2089.  
  2090. DRAFT                  File distribution - dialog                  DRAFT
  2091.  
  2092.  
  2093.                     -- A directory is started with a
  2094.                     -- [DIR] and closed with a [RID].
  2095.                     -- A sophisticated user agent could
  2096.                     -- hide [RID] lines from a human, as
  2097.                     -- they are only intended to ease
  2098.                     -- the parsing. [RID]-lines are not
  2099.                     -- needed for non-recursive message.
  2100.         
  2101.         <LISTING-file> ::=
  2102.             <N-line>
  2103.             <LIST-line>*
  2104.         
  2105.         <SOURCE-line> ::=
  2106.             SOURCE: <SP>* <addr> <SP>* <(> <explanation> <)>
  2107.             <CR>
  2108.                     -- This is the source of this
  2109.                     -- command file. It includes the
  2110.                     -- e-mail address of the source as
  2111.                     -- well as a human readable name for
  2112.                     -- it.
  2113.         
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146. Kaittola                 Expires: January, 1994                [Page 37]
  2147.  
  2148. DRAFT                  File distribution - dialog                  DRAFT
  2149.  
  2150.  
  2151. Appendix D: Checksum function by Pasi Ojala
  2152.         
  2153.         long calcsum(size,buf)
  2154.         int size;               /* number of elements, 0-11 */
  2155.         long *buf;              /* 24-bit values */
  2156.         {
  2157.             int i,j,a,index=0;
  2158.             static int cs0=0,cs1=0,cs2=0;    /* Initialize to 0 
  2159.                             only once */
  2160.             long value;
  2161.          
  2162.             /* Matrix columns */
  2163.             static char a0[]={0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
  2164.                       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  2165.                       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  2166.                       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  2167.                       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
  2168.             static char a1[]={1,1,1,1,1,1,1,1,3,3,0,0,0,0,0,0,0,0,
  2169.                       1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,
  2170.                       3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,
  2171.                       5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,
  2172.                       7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8};
  2173.             static char a2[]={1,2,3,4,5,6,7,8,1,2,1,2,3,4,5,6,7,8,
  2174.                       0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8,
  2175.                       0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8,
  2176.                       0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8,
  2177.                       0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6};
  2178.          
  2179.             for(i=0;i<size;i++)         /* Handle all elements */
  2180.             {
  2181.                 value = buf[i];         /* Get the next 24 bits */
  2182.                 for(j=0;j<8;j++)        /* Make it 8*3 bits */
  2183.                 {
  2184.                     if((a=(value & 0x07)))      /* Get 3 bits */
  2185.                     {
  2186.                         cs0 += a0[index] * a;   /* Matrix */
  2187.                         cs1 += a1[index] * a;    /* multiplication */
  2188.                         cs2 += a2[index] * a;
  2189.                     }
  2190.                     value >>= 3;  /* Forget the processed 3 bits */
  2191.                     index++;  /* Go to the next row in the matrix */
  2192.                 }
  2193.             }
  2194.             cs0 %= 9;   /* Convert to a remainder class */
  2195.             cs1 %= 9;   /* These can be outside of the loop, */
  2196.             cs2 %= 9;   /* because 88*9*8 = 6336, which fits into */
  2197.                 /* integer nicely */
  2198.             /* return a 12-bit checksum */
  2199.             return ((cs0<<8) | (cs1<<4) | cs2);
  2200.         }
  2201.  
  2202.  
  2203.  
  2204. Kaittola                 Expires: January, 1994                [Page 38]
  2205.